#ifndef BATTLEGAME_H
#define BATTLEGAME_H
#include <QObject>
#include <QString>
#include <QTextStream>
#include "Fleet.h"
#include "InvalidBoatName.h"
#include "DoubleFiredPoint.h"
#include "OutOfBound.h"
#include "OverlapBoat.h"
#include "TooNearBoat.h"
#include "Point.h"
#include "ToDoBoatList.h"
#include "Arena.h"
#include "AiPlayer.h"
#include "TurnManager.h"

class BattleGame : public QObject {
	Q_OBJECT

	public:
		BattleGame(int, const ToDoBoatList&, const ToDoBoatList&);
		virtual ~BattleGame();
	
	public slots:
		void leftClickedCampo1(const Point<int>&);
		void rightClickedCampo1(const Point<int>&);
		void doubleClickedCampo1(const Point<int>&);
		void focusOnCampo1(const Point<int>&);
		void leftClickedCampo2(const Point<int>&);
		void rightClickedCampo2(const Point<int>&);
		void doubleClickedCampo2(const Point<int>&);
		void focusOnCampo2(const Point<int>&);
		void setTurnManager(TurnManager*);

	signals:
		void arenaPlayer1Changed(Arena*);
		void arenaPlayer2Changed(Arena*);
		void helpChanged(const QString&);
		void errorChanged(const QString&);
		void winnerPlayer1();
		void winnerPlayer2();
		void numberBoatPlayer1Changed(int);
		void numberBoatPlayer2Changed(int);
		void gameMessagePlayer1(const QString&);
		void gameMessagePlayer2(const QString&);
	
	private:
		void automaticCreateFleet(Fleet*, Arena*&, ToDoBoatList&);
		Fleet* flotta1;
		Fleet* flotta2;
		Arena* campo1;
		Arena* campo2;
		bool status;
		Point<int> lastPoint;
		int dim;
		ToDoBoatList toDoBoatList1;
		ToDoBoatList toDoBoatList2;
		AiPlayer virtualPlayer;
		TurnManager* turnManager;
};

#endif
